﻿<UserControl x:Class="Ewav.MapControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:GadgetSelector="clr-namespace:Ewav.ContextMenu;assembly=Ewav.ContextMenu.Menu"
             xmlns:Common="clr-namespace:CommonLibrary;assembly=CommonLibrary"
             mc:Ignorable="d"
             d:DesignHeight="610" d:DesignWidth="700"
             xmlns:bing="clr-namespace:ESRI.ArcGIS.Client.Bing;assembly=ESRI.ArcGIS.Client.Bing"                 
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"              
             DataContext="{Binding Source={StaticResource Locator}, Path=MapControlViewModel}"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
             xmlns:esri="http://schemas.esri.com/arcgis/client/2009">

    <UserControl.Resources>

        <Style x:Key="ButtonStyleMap" TargetType="Button">
            <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
            <Setter Property="FontSize" Value="14.667" />
            <Setter Property="FontFamily" Value="Segoe UI" />
            <Setter Property="Padding" Value="10,0,10,2" />
            <Setter Property="MinHeight" Value="30" />
            <Setter Property="MinWidth" Value="30" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonHoverBackgroundBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="Stroke">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonHoverBorderBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonPressedBackgroundBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="Stroke">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonPressedBorderBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentControl">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource LightForegroundBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DisabledVisualElement">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="FocusedVisualElement">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle x:Name="Bd" Fill="{StaticResource ButtonBackgroundBrush}" Stroke="{StaticResource ButtonBorderBrush}" StrokeThickness="1" />
                            <ContentControl x:Name="ContentControl" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0,0,0,2">
                                <ContentPresenter x:Name="contentPresenter" />
                            </ContentControl>
                            <Rectangle x:Name="FocusedVisualElement" Stroke="{StaticResource ButtonPressedBorderBrush}" Visibility="Collapsed" StrokeThickness="2" />
                            <Rectangle x:Name="DisabledVisualElement" Fill="{StaticResource DisabledVisualElement}" Visibility="Collapsed" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="MapNavigationStyle" TargetType="esri:Navigation">
            <Setter Property="Background" Value="#FF949494"/>
            <Setter Property="Foreground" Value="#FF333333"/>
            <Setter Property="BorderBrush" Value="White"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="esri:Navigation">
                        <Grid x:Name="LayoutRoot" Background="#00FFFFFF" HorizontalAlignment="Left" MinWidth="148" MinHeight="125" RenderTransformOrigin="{TemplateBinding RenderTransformOrigin}" VerticalAlignment="Top" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RenderTransform>
                                <ScaleTransform CenterY="0" CenterX="0"/>
                            </Grid.RenderTransform>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0:0:0.1" To="0.75" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" Storyboard.TargetName="LayoutRoot"/>
                                            <DoubleAnimation Duration="0:0:0.1" To="0.75" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" Storyboard.TargetName="LayoutRoot"/>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="0:0:0.1" To="0.25" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LayoutRoot"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="0:0:0.1" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" Storyboard.TargetName="LayoutRoot"/>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="0:0:0.1" To="1" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" Storyboard.TargetName="LayoutRoot"/>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="0:0:0.1" To="0.75" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LayoutRoot"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="ZoomContainer" Margin="0" VerticalAlignment="Center">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Rectangle Grid.ColumnSpan="4" Fill="{TemplateBinding Background}" Margin="0,0,0,0" RadiusY="3" RadiusX="3" Grid.RowSpan="4" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
                                <Button x:Name="ZoomInButton" Content="+" Foreground="{TemplateBinding Foreground}" FontSize="8" Height="16" Margin="2,2,2,0" Grid.Row="0" ToolTipService.ToolTip="Zoom In" Width="14" Style="{StaticResource ButtonStyleMap}" MinWidth="0" MinHeight="0"/>
                                <Rectangle Fill="White" HorizontalAlignment="Center" Height="3" Grid.Row="1" VerticalAlignment="Center" Width="2"/>
                                <Slider x:Name="ZoomSlider" Cursor="Hand" Height="89" LargeChange="1" Maximum="15" Minimum="0" Orientation="Vertical" Grid.Row="1" SmallChange="1" ToolTipService.ToolTip="Drag to zoom in or out" Value="0" VerticalAlignment="Top"/>
                                <Button x:Name="ZoomOutButton" Content="-" Foreground="{TemplateBinding Foreground}" FontSize="8" Height="16" Margin="2,0,2,2" Grid.Row="2" ToolTipService.ToolTip="Zoom Out" Width="14" Style="{StaticResource ButtonStyleMap}" MinWidth="0" MinHeight="0"/>
                            </Grid>
                            <Grid x:Name="Navigator" Grid.Column="1" Height="125" Margin="3,0,0,0" RenderTransformOrigin="0.5,0.5" Width="125">
                                <Grid.RenderTransform>
                                    <RotateTransform x:Name="TransformRotate" Angle="0"/>
                                </Grid.RenderTransform>
                                <Path x:Name="RotateRing" Cursor="Hand" Data="M97.050499,68.386246 L106.5,68.386246 L106.1507,69.74157 C101.85528,83.519669 92.276138,94.975006 79.777817,101.74873 C76.653244,103.44215 73.34623,104.84298 69.893723,105.91433 L69.5,106.01534 L69.5,96.482994 L71.447334,95.771919 C74.205498,94.608025 76.826485,93.184006 79.279457,91.530655 C84.185387,88.223969 88.419128,84.000031 91.733521,79.105515 C93.390709,76.658241 94.818054,74.043327 95.98465,71.29158 z M0.5,68.386246 L9.9494915,68.386246 L11.015333,71.29158 C12.181933,74.043343 13.609276,76.658241 15.266468,79.105515 C18.580849,84.000053 22.814623,88.223969 27.720554,91.530655 C30.173519,93.18399 32.794529,94.608032 35.552677,95.771912 L38.5,96.848145 L38.5,106.27186 L37.106312,105.91433 C23.296202,101.62891 11.814036,92.07193 5.0245867,79.602684 C3.3272135,76.485374 1.923135,73.186035 0.8492955,69.741547 z M69.5,0.75652671 L69.893661,0.85751152 C83.703682,5.14291 95.185875,14.699864 101.97538,27.169144 C103.67275,30.286457 105.07684,33.585789 106.15069,37.030285 L106.5,38.38562 L97.050507,38.38562 L95.984657,35.480282 C94.818062,32.728535 93.390701,30.113619 91.733528,27.666359 C88.419121,22.771801 84.185356,18.547873 79.279427,15.241194 C76.826447,13.58785 74.205452,12.163824 71.447311,10.999947 L69.5,10.288876 z M38.5,0.5 L38.5,9.9237194 L35.552654,10.999952 C32.794514,12.163842 30.173498,13.587873 27.720541,15.241213 C22.81461,18.547897 18.580839,22.771828 15.266464,27.666361 C13.609274,30.113626 12.181928,32.728542 11.015331,35.480286 L9.9494915,38.38562 L0.5,38.38562 L0.84929955,37.030308 C5.1446834,23.252361 14.723901,11.796858 27.222183,5.02314 C30.346762,3.3297043 33.653778,1.928881 37.106293,0.85752773 z" Fill="{TemplateBinding Background}" Margin="8" Stretch="Fill" Stroke="{TemplateBinding BorderBrush}" ToolTipService.ToolTip="Drag to rotate"/>
                                <Grid x:Name="PanLeft" Cursor="Hand" HorizontalAlignment="Left" Margin="0" ToolTipService.ToolTip="Click to move west" VerticalAlignment="Center" Width="25">
                                    <Ellipse Fill="{TemplateBinding Background}" Height="24.5" Stroke="{TemplateBinding BorderBrush}" Width="25"/>
                                    <Path Data="M48,71 L40,76 L48,81 z" Fill="#FFFFFFFF" Height="13" Canvas.Left="7" Margin="7.836,6,9.164,6" Stretch="Fill" Stroke="#FFFFFFFF" Canvas.Top="5.75" Width="8"/>
                                </Grid>
                                <Grid x:Name="PanRight" Cursor="Hand" HorizontalAlignment="Right" Margin="0" RenderTransformOrigin="0.5,0.5" ToolTipService.ToolTip="Click to move east" VerticalAlignment="Center" Width="25">
                                    <Grid.RenderTransform>
                                        <RotateTransform Angle="180"/>
                                    </Grid.RenderTransform>
                                    <Ellipse Fill="{TemplateBinding Background}" Height="24.5" Stroke="{TemplateBinding BorderBrush}" Width="25"/>
                                    <Path Data="M48,71 L40,76 L48,81 z" Fill="#FFFFFFFF" Height="13" Canvas.Left="7" Margin="7.836,6,9.164,6" Stretch="Fill" Stroke="#FFFFFFFF" Canvas.Top="5.75" Width="8"/>
                                </Grid>
                                <Grid x:Name="PanUp" Cursor="Hand" HorizontalAlignment="Center" Height="25" Margin="0" RenderTransformOrigin="0.5,0.5" ToolTipService.ToolTip="Click to move north" VerticalAlignment="Top">
                                    <Grid.RenderTransform>
                                        <RotateTransform Angle="90"/>
                                    </Grid.RenderTransform>
                                    <Ellipse Fill="{TemplateBinding Background}" Height="24.5" Stroke="{TemplateBinding BorderBrush}" Width="25"/>
                                    <Path Data="M49.643433,70.53167 L37.857143,76 L49.572575,81.46917 z" Fill="#FFFFFFFF" Height="14.125" Canvas.Left="4.906" Margin="5.672,5.5,8.015,5.375" Stretch="Fill" Stroke="#FFFFFFFF" Canvas.Top="4.906" Width="11.313"/>
                                    <Path Data="M92,29.833334 L92.000114,24.166691 L93.247681,24.184656 L96.134811,27.716934 L96.076241,24.166662 L97.444435,24.166662 L97.444435,29.833332 L96.218758,29.810295 L93.332748,26.418152 L93.361107,29.808037 z" Fill="{TemplateBinding Foreground}" Height="5.322" Canvas.Left="10.746" RenderTransformOrigin="0.506,0.5" Stretch="Fill" Canvas.Top="9.367" Width="4.416">
                                        <Path.RenderTransform>
                                            <RotateTransform Angle="90"/>
                                        </Path.RenderTransform>
                                    </Path>
                                    <Path Data="M91.666664,39" Fill="#FF000000" Height="1" Canvas.Left="10.375" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Stroke="#FF000000" Canvas.Top="9.417" Width="1">
                                        <Path.RenderTransform>
                                            <TransformGroup>
                                                <RotateTransform Angle="90"/>
                                                <TranslateTransform X="3.5064478404741046" Y="0.50863583808085222"/>
                                            </TransformGroup>
                                        </Path.RenderTransform>
                                    </Path>
                                </Grid>
                                <Grid x:Name="PanDown" Cursor="Hand" HorizontalAlignment="Center" Height="25" Margin="0" RenderTransformOrigin="0.5,0.5" ToolTipService.ToolTip="Click to move south" VerticalAlignment="Bottom">
                                    <Grid.RenderTransform>
                                        <RotateTransform Angle="270"/>
                                    </Grid.RenderTransform>
                                    <Ellipse Fill="{TemplateBinding Background}" Height="24.5" Stroke="{TemplateBinding BorderBrush}" Width="25"/>
                                    <Path Data="M48,71 L40,76 L48,81 z" Fill="#FFFFFFFF" Height="13" Canvas.Left="7" Margin="7.172,6,9.828,6" Stretch="Fill" Stroke="#FFFFFFFF" Canvas.Top="5.75" Width="8"/>
                                </Grid>
                            </Grid>
                            <Button Name="ZoomFullExtent" BorderBrush="{TemplateBinding BorderBrush}" Cursor="Hand" Grid.Column="1" HorizontalAlignment="Center" Height="20" ToolTipService.ToolTip="Full Extent" VerticalAlignment="Center" Width="20" Style="{StaticResource ButtonStyleMap}">
                                <Grid Height="14" Width="14">
                                    <Ellipse Height="Auto" Stroke="{TemplateBinding Foreground}" Width="Auto"/>
                                    <Ellipse Height="6" Stroke="{TemplateBinding Foreground}" Width="Auto"/>
                                    <Ellipse Height="Auto" Stroke="{TemplateBinding Foreground}" Width="6"/>
                                </Grid>
                            </Button>
                            <Button x:Name="ResetRotation" BorderBrush="{TemplateBinding BorderBrush}" Cursor="Hand" Grid.Column="1" HorizontalAlignment="Left" Height="20" Margin="3,0,0,0" ToolTipService.ToolTip="Reset North" VerticalAlignment="Bottom" Width="20" Style="{StaticResource ButtonStyleMap}" Visibility="Collapsed">
                                <Grid HorizontalAlignment="Left" Height="Auto" RenderTransformOrigin="0.5,0.5" Width="Auto">
                                    <Grid.RenderTransform>
                                        <RotateTransform Angle="0"/>
                                    </Grid.RenderTransform>
                                    <Path Data="M49.643433,70.53167 L37.857143,76 L49.572575,81.46917 z" Fill="{TemplateBinding Background}" Height="12" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Width="10">
                                        <Path.RenderTransform>
                                            <RotateTransform Angle="90"/>
                                        </Path.RenderTransform>
                                    </Path>
                                    <Path Data="M92,29.833334 L92.000114,24.166691 L93.247681,24.184656 L96.134811,27.716934 L96.076241,24.166662 L97.444435,24.166662 L97.444435,29.833332 L96.218758,29.810295 L93.332748,26.418152 L93.361107,29.808037 z" Fill="{TemplateBinding Foreground}" Height="4" Margin="0,3,0,0" Stretch="Fill" Width="4"/>
                                </Grid>
                            </Button>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Storyboard x:Name="Shrink">
            <!--<DoubleAnimation Storyboard.TargetName="Legend1" Storyboard.TargetProperty="Height" From="228" To="0" Duration="00:00:00.5" />-->
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Legend1" Storyboard.TargetProperty="(UIElement.Visibility)" BeginTime="00:00:00">
                <DiscreteObjectKeyFrame KeyTime="00:00:00.2">
                    <DiscreteObjectKeyFrame.Value>
                        <Visibility>Collapsed</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <DoubleAnimation Duration="00:00:00.2" From="1.00" To="0.00" Storyboard.TargetName="Legend1" Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
        <Storyboard x:Name="Grow">
            <!--<DoubleAnimation Storyboard.TargetName="spButtons" Storyboard.TargetProperty="Height" From="0" To="228" Duration="00:00:00.5" />-->
            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Legend1" Storyboard.TargetProperty="(UIElement.Visibility)" BeginTime="00:00:00">
                <DiscreteObjectKeyFrame KeyTime="00:00:00.0">
                    <DiscreteObjectKeyFrame.Value>
                        <Visibility>Visible</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
            </ObjectAnimationUsingKeyFrames>
            <DoubleAnimation Duration="00:00:00.2" From="0.00" To="1.00" Storyboard.TargetName="Legend1" Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White"  MouseRightButtonDown="LayoutRoot_MouseRightButtonDown" MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown" MouseLeftButtonUp="LayoutRoot_MouseLeftButtonUp" MouseMove="LayoutRoot_MouseMove">
        <Grid x:Name="GadgetWindow" Background="White" MinWidth="600"  >
			<Grid.RowDefinitions>
        		<RowDefinition Height="50"/>
        		<RowDefinition/>
        	</Grid.RowDefinitions>
        	<Grid.ColumnDefinitions>
        		<ColumnDefinition Width="Auto"/>
        		<ColumnDefinition/>
        	</Grid.ColumnDefinitions>
            <Rectangle x:Name="GWindow" Style="{StaticResource GWindow}" Stroke="{StaticResource WindowBrush}" StrokeThickness="4" Grid.ColumnSpan="2" Grid.RowSpan="2" />
            <StackPanel d:LayoutOverrides="VerticalAlignment, GridBox" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="13,11,0,0">
                <TextBlock x:Name="GName" TextWrapping="Wrap" Text="Case Cluster Map"     VerticalAlignment="Top" Margin="0,0,26,0" Height="Auto" HorizontalAlignment="Left" Foreground="#FF2B4360" FontSize="21.333"/>

                <Rectangle x:Name="GHeader" VerticalAlignment="Top" Height="4" Margin="0,2,0,0" StrokeThickness="0" Fill="#FF00B050" />
            </StackPanel>
            <StackPanel HorizontalAlignment="Right" Margin="180,9,11,0" Orientation="Horizontal" VerticalAlignment="Top" Grid.Column="1">
                <Button x:Name="FilterButton" Content=""  Template="{StaticResource FilterButton}" Cursor="Hand" Click="FilterButton_Click" Width="24" Height="24" IsEnabled="False">
                	<Button.Effect>
                		<DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
                	</Button.Effect>
                </Button>
                <Button x:Name="HeaderButton" Content="" Template="{StaticResource HeaderButton}" Cursor="Hand" Click="HeaderButton_Click"  Width="24" Height="24" >
                	<Button.Effect>
                		<DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
                	</Button.Effect>
                </Button>
                <Button x:Name="ResizeButton" Content="" Template="{StaticResource resizebtn}" Cursor="Hand"  Width="24" Height="24" Click="ResizeButton_Click">

                    <Button.Effect>
                        <DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
                    </Button.Effect>
                </Button>
                <Button x:Name="btnClose" Content="" Template="{StaticResource CloseButton}" Cursor="Hand"             Height="24" Click="CloseButton_Click">
                    <Button.Effect>
                        <DropShadowEffect Color="#FFB0B0B0" ShadowDepth="1"/>
                    </Button.Effect>
                </Button>
            </StackPanel>
            <Grid x:Name="GadgetContentGrid" Grid.Row="1" Margin="0,5,0,10" MinHeight="30" Grid.ColumnSpan="2">

                <toolkit:Expander Margin="180,-45,131,0" VerticalAlignment="Top"  x:Name="gadgetExpander" IsExpanded="True"
                                  ExpandDirection="Down" Style="{StaticResource ExpanderStyle2}" Canvas.ZIndex="999" HorizontalAlignment="Right">

                    <toolkit:Expander.Header>
                        <TextBlock Text="Edit Properties" FontFamily="Segoe UI" Cursor="Hand" FontSize="13.333" FontWeight="Normal" Foreground="White" />
                    </toolkit:Expander.Header>
                    <Grid Background="#FF5C53AC" HorizontalAlignment="Right" Margin="0,-2,1,0">
                        <StackPanel Orientation="Vertical" Margin="10,5,10,10" HorizontalAlignment="Center" VerticalAlignment="Top" >
                            <TextBlock x:Name="tblockLatitude" TextAlignment="Center" Text="Latitude:" VerticalAlignment="Top" Foreground="White" HorizontalAlignment="Left"  />
                            <ComboBox x:Name="cbxLatitude" Width="160" SelectedIndex="0" Height="25" Margin="0,3,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left" HorizontalAlignment="Left" UseLayoutRounding="False" />
                            <TextBlock x:Name="tbLongitude" TextAlignment="Center" Text="Longitude:" VerticalAlignment="Top" Margin="0,5,0,0" Foreground="White" HorizontalAlignment="Left"  />
                            <ComboBox x:Name="cbxLongitude" Width="160" SelectedIndex="0" Height="25" Margin="0,3,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left" HorizontalAlignment="Left" UseLayoutRounding="False" />
                            <TextBlock x:Name="tbStratify" TextAlignment="Center" Text="Stratify By:" VerticalAlignment="Top" Margin="0,5,0,0" Foreground="White" HorizontalAlignment="Left"  />
                            <ComboBox x:Name="cbxStratify" Width="160" SelectedIndex="0" Height="25" Margin="0,3,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Left" HorizontalAlignment="Left" UseLayoutRounding="False" />
                            <toolkit:Expander x:Name="exAdvancedOptions" Margin="0,10" ExpandDirection="Down" MouseLeftButtonDown="LayoutRoot_MouseRightButtonDown" Style="{StaticResource ExpanderStyle}" Foreground="White" Width="175" IsExpanded="False">
                                <toolkit:Expander.Header>
                                    <TextBlock Text="Advanced Options" Cursor="Hand" Foreground="White"/>
                                </toolkit:Expander.Header>
                                <StackPanel Orientation="Vertical" Margin="-2,2" VerticalAlignment="Top" MinHeight="165" HorizontalAlignment="Left">
                                    <TextBlock x:Name="tbClusterSize" TextAlignment="Center" Text="Max Cluster Size:" VerticalAlignment="Top" Margin="0,5,0,0" Foreground="White" HorizontalAlignment="Left"  />
                                    <toolkit:NumericUpDown x:Name="udClusterSize" HorizontalAlignment="Left" VerticalAlignment="Top" 
                                                           Height="30" Style="{StaticResource NumericUpDownStyle1}" 
                                                           Width="101" Minimum="5" Maximum="20" Value="10" Foreground="#FF3F3F3F"/>
                                    <TextBlock x:Name="tbRadius" 
                                               TextAlignment="Center" Text="Radius (px):" VerticalAlignment="Top" Margin="0,5,0,0" Foreground="White" HorizontalAlignment="Left"  d:LayoutOverrides="HorizontalAlignment"  />
                                    <toolkit:NumericUpDown x:Name="udRadius" HorizontalAlignment="Left" VerticalAlignment="Top"
                                                           Height="30" Style="{StaticResource NumericUpDownStyle1}" 
                                                           Width="101" Minimum="10" Maximum="1000" Increment="10" 
                                                           Value="10" Foreground="#FF3F3F3F"/>
                                    <TextBlock TextAlignment="Center" Text="Width:" VerticalAlignment="Top" Margin="0,5,0,0" Foreground="White" HorizontalAlignment="Left"  d:LayoutOverrides="HorizontalAlignment"  />
                                    <toolkit:NumericUpDown x:Name="udWidth" HorizontalAlignment="Left" VerticalAlignment="Top" 
                                                           Height="30" Style="{StaticResource NumericUpDownStyle1}" Width="65" 
                                                           Minimum="600" Maximum="2000" Increment="10" 
                                                           d:LayoutOverrides="HorizontalAlignment" Foreground="#FF3F3F3F"/>
                                    <TextBlock  TextAlignment="Center" Text="Height:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="93,-51,0,0" Foreground="White"  />
                                    <toolkit:NumericUpDown x:Name="udHeight" HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Style="{StaticResource NumericUpDownStyle1}" Width="65" Minimum="480" Maximum="1000" Increment="10" Margin="93,-30,0,0" Foreground="#FF3F3F3F"/>
                                    <RadioButton Content="Show Road View"    Name="rbRoads" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,7,0,0" GroupName="rbgrpView" Foreground="White" IsChecked="True"/>
                                    <RadioButton Content="Show Satellite View"    Name="rbSatellite" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0" GroupName="rbgrpView" Foreground="White"/>

                                </StackPanel>
                            </toolkit:Expander>
                            <Button x:Name="btnRun" Content="Run Gadget" VerticalAlignment="Top" Margin="0" Style="{StaticResource btnSec}" Height="30"     Click="btnRun_Click" HorizontalAlignment="Left" Padding="10,3" Width="168"   />
                        </StackPanel>
                    </Grid>
                </toolkit:Expander>

                <StackPanel x:Name="spContent" Orientation="Vertical" Margin="10,6,10,10" Visibility="Collapsed">
                    <TextBlock x:Name="txtGadgetDescription" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="3,3,0,6" d:LayoutOverrides="HorizontalMargin" MaxWidth="650" Padding="0,0,10,0" />
                    <StackPanel x:Name="pnlStatus" Height="40" MaxHeight="40" Width="Auto" Background="#FFf8d7e2" VerticalAlignment="Top" Margin="0,5" Visibility="Collapsed" HorizontalAlignment="Left">
                        <StackPanel x:Name="pnlStatusTop" Height="2" Width="Auto" Background="#FFe4658e"/>
                        <Image x:Name="ErrorIcon" Source="/Ewav;component/Images/error.png" Width="18" Height="18" HorizontalAlignment="Left" Margin="5,1,5,0" VerticalAlignment="Center"/>
                        <TextBlock x:Name="txtStatus" Text="Error: Exception occurred." TextWrapping="Wrap" Margin="30,-15,5,5" HorizontalAlignment="Left" FontWeight="Bold" VerticalAlignment="Center"/>
                    </StackPanel>
                    <StackPanel x:Name="panelMain" Visibility="Collapsed" HorizontalAlignment="Left">
                        <Grid VerticalAlignment="Top">
                            <Canvas MouseLeftButtonDown="Canvas_MouseLeftButtonDown" Height="{Binding Height, ElementName=map1}" Width="{Binding Width, ElementName=map1}" >
                                <esri:Map x:Name="map1"  VerticalAlignment="Top"  WrapAround="True"         
                                          ZoomDuration="00:00:02" PanDuration="00:00:02"      
                                          Height="540"  MouseLeftButtonDown="map1_MouseLeftButtonDown" 
                                          MouseLeftButtonUp="map1_MouseLeftButtonUp"    MouseMove="map1_MouseMove"   
                                          Width="700"     >
                                </esri:Map>    
                                
                                <esri:Navigation Margin="5,20,5,5" HorizontalAlignment="Left" VerticalAlignment="Top" Map="{Binding ElementName=map1}" Style="{StaticResource MapNavigationStyle}" />
                            </Canvas>
                            <StackPanel HorizontalAlignment="Left" Orientation="Vertical" d:LayoutOverrides="Height" VerticalAlignment="Bottom">
                                <Border x:Name="Legend1" VerticalAlignment="Bottom" Background="#CAFFFFFF" BorderBrush="#FF00aade" BorderThickness="2"  Visibility="Collapsed" >
                                    <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="250">
                                    <StackPanel x:Name="Legend2" Margin="10" Orientation="Vertical"  />
                                    </ScrollViewer>
                                </Border>
                                <Button x:Name="btnLegend" Content="Legend" Click="btnLegend_Click" VerticalAlignment="Bottom" Cursor="Hand" Canvas.ZIndex="1"  Height="33" HorizontalAlignment="Left" Padding="9,3" Visibility="Collapsed"/>
                                <!--<ToggleButton x:Name="btnToggleView" Content="Road View" Checked="btnToggleView_ViewChanged" Unchecked="btnToggleView_ViewChanged" Margin="85,-32,0,0" Width="107" />-->
                            </StackPanel>

                        </Grid>
                    </StackPanel>

                </StackPanel>
                <Grid x:Name="waitCursor" Background="#36C4C4C4" Height="Auto" Visibility="Collapsed">
                    <toolkit:BusyIndicator x:Name="BusyIndicator" IsBusy="True" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="100" />
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</UserControl>